<style scoped>

</style>
<template>
    <el-dialog
            :destroy-on-close="true"
            :modal="true"
            :modal-append-to-body="false"
            :append-to-body="true"
            :visible.sync="isShow"
            :before-close="beforeClose"
            title="提示"
            width="30%">
        <p slot="title" style="color: #333;">{{dialogName}}</p>
        <el-form size="small" ref="dialog_form" :model="formData" :rules="formRules" label-position="left"
                 label-width="120px">
            <el-form-item label="名称" prop="name">
                <el-input placeholder="请输入名称" v-model="formData.name" :maxlength="30"
                ></el-input>
            </el-form-item>
        </el-form>
        <span class="dialog-footer" slot="footer">
            <el-button @click="isShow = false">取 消</el-button>
            <el-button @click="clickSave" type="primary">确认</el-button>
        </span>
    </el-dialog>
</template>

<script>

    export default {
        name: "SoftListEditDialog",
        data() {
            return {
                name: '',
                isShow: false,
                dialogName: '',
                formData: {},
                formRules: {
                    name: [
                        {required: true, message: '请输入列表名称', trigger: 'change'},
                    ]
                }
            }
        },
        methods: {

            open(data={}) {
                let form = JSON.parse(JSON.stringify(data))
                if (data && data.id) {
                    this.dialogName = "编辑" + name
                    this.formData = {}
                } else {
                    this.dialogName = '新增' + name
                    this.formData = {}
                }

                this.formData = Object.assign({}, this.formData, form)
                this.isShow = true
            },
            save() {
                let req_data = JSON.parse(JSON.stringify(this.formData))

            },
            clickSave() {
                this.$refs['dialog_form'].validate((valid) => {
                    if (valid) {
                        this.save()
                    }
                })
            },
            beforeClose() {
                let form = this.$refs['dialog_form']
                form.clearValidate()
                form.resetFields()
                this.isShow = false
            },
            close() {
                this.isShow = false
            },
        }
    }
</script>
